﻿using System;
using ePipe;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Letter.Net.Sockets;

sealed class TcpRcver : ASocketRcver
{
    public TcpRcver(PipeScheduler ioScheduler) : base(ioScheduler)
    {
    }

    public ValueTask<SocketOperationResult> WaitAsync(Socket socket)
    {
        return base.ReceiveAsync(socket, Memory<byte>.Empty);
    }

    public new ValueTask<SocketOperationResult> ReceiveAsync(Socket socket, Memory<byte> buffer)
    {
        return base.ReceiveAsync(socket, buffer);
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    protected override bool SocketRcvOperationAsync(Socket socket)
    {
        return socket.ReceiveAsync(this);
    }
}